{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是一个 POST 请求的响应\n",
      "这是一个 GET 请求的响应\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "  \n",
    "header = {\n",
    "  \"content-type\": \"application/x-www-form-urlencoded\"\n",
    "}\n",
    "\n",
    "# 发送字典\n",
    "post_dict = {\n",
    "  \"body\": \"kw=sympathy\",\n",
    "  \"method\": \"POST\"\n",
    "}\n",
    "\n",
    "r1 = requests.post('http://localhost:3000/api', data=post_dict, headers=header)\n",
    "r2 = requests.get('http://localhost:3000/api')\n",
    "\n",
    "# print(\"r1返回的内容为-->\" + r1.text)\n",
    "\n",
    "print(r1.text)\n",
    "print(r2.text)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
